using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TaugeFramework.UserControls
{
    enum eMessagingBoxType 
    {
        Error,
        Success
    }

    partial class MessagingBox : UserControl
    {
        /*
        private Color m_color_error;
        private Color m_color_success;
        */
        private bool m_usetimer;
        private DateTime m_hideon;
        

        public MessagingBox()
        {
            InitializeComponent();
            /*
            m_color_error = Color.Salmon;
            m_color_success = Color.LightGreen;
             * */
            m_usetimer = false;
            this.Visible = false;
            timer1.Enabled = false;
        }

        public void ShowBox(string msg, eMessagingBoxType etipe)
        {
            /*
            if (etipe == eMessagingBoxType.Error)
                this.BackColor = m_color_error;
            else
                this.BackColor = m_color_success;
            */

            if (etipe == eMessagingBoxType.Error)
                this.BackgroundImage = TaugeFramework.Properties.Resources.Background_Gradient_Red;
            else
                this.BackgroundImage = TaugeFramework.Properties.Resources.Background_Gradient_Green;

            this.lblMessage.Text = msg;
            this.Visible = true;
        }

        public void ShowBox(string msg, eMessagingBoxType etipe, int nsecond)
        {
            ShowBox(msg, etipe);
            m_hideon = DateTime.Now.AddSeconds(nsecond);
            m_usetimer = true;
            timer1.Enabled = true;
        }


        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (m_usetimer)
                if (DateTime.Now >= m_hideon)
                {
                    this.Visible = false;
                    timer1.Enabled = false;
                }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            this.Visible = false;
        }
    }
}
